home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 21.zip / BS1 part 21 / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].7z / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].adf / rexx.lzh / Align.pprx < prev    next >
Text File  |  1992-03-13  |  4KB  |  144 lines

  1. /*
  2. @BAlign  @P@ICopyright Gold Disk Inc., February, 1992
  3. This Genie aligns multiple boxes at a specified position. Click on each box to be aligned and then click on the artboard or in empty space when finished selecting boxes.
  4. */
  5. cr     = '0a'x
  6. counter     = 0
  7. address command
  8. call SafeEndEdit.rexx()
  9. units = ppm_GetUnits()
  10. if units = 3 then
  11.     call ppm_SetUnits(1)
  12.  
  13. signal on halt
  14. signal on break_c
  15. signal on break_e
  16. signal on break_d
  17.  
  18. /* Prompt user to click on boxes to be aligned
  19.  * if the user clicks on the page or the art board
  20.  * a boxnumber of 0 will be returned, use that
  21.  * to exit loop
  22.  */
  23. do forever
  24.  
  25.     box = ppm_ClickOnBox( "Click on boxes to be aligned" )
  26.  
  27.     if box = 0 then leave
  28.  
  29.     counter = counter + 1
  30.     boxes.counter = box /*  store box number in compound variable   */
  31.     call ppm_SelectBox(box)
  32.  
  33. end
  34.  
  35. if counter = 0 then exit_msg()
  36. /*  Prompt use to enter alignment - L, R, T, B, CV, CH   */
  37. align = "Left"cr"Right"cr"Top"cr"Bottom"cr"Center Vertically"cr"Center Horizontally"
  38. align = ppm_SelectFromList("Select alignment..", 30, 5, 0, align)
  39. if align = '' then exit_msg()
  40.  
  41. select 
  42.    when align = 'Left' then pos = word(ppm_GetBoxPosition(boxes.1),1)
  43.    when align = 'Right' then pos = word(ppm_GetBoxPosition(boxes.1),1) + word(ppm_GetBoxSize(boxes.1),1)
  44.    when align = 'Top' then pos = word(ppm_GetBoxPosition(boxes.1),2)
  45.    when align = 'Bottom' then pos = word(ppm_GetBoxPosition(boxes.1),2) + word(ppm_GetBoxSize(boxes.1),2)
  46.    when align = 'Center Horizontally' then pos = word(ppm_GetBoxPosition(boxes.1),2) + word(ppm_GetBoxSize(boxes.1),2) / 2
  47.    when align = 'Center Vertically' then pos = word(ppm_GetBoxPosition(boxes.1),1) + word(ppm_GetBoxSize(boxes.1),1) / 2
  48. end
  49.  
  50. if units = 3 then
  51.     pos = ppm_ConvertUnits(1,3, pos)
  52.  
  53. position = ppm_GetForm( "Enter Position", 8, "Position:"pos)
  54. if position = '' then exit_msg()
  55.  
  56. if ~datatype(position, n) then
  57.     call exit_msg('Invalid Input')
  58.  
  59. if units = 3 then
  60.    position = ppm_ConvertUnits(3, 1, position)
  61.  
  62. /*  Create a function to align the boxes    */
  63. newpos = ''
  64. newpos = SetAlignment(align)
  65.  
  66. call ppm_AutoUpdate(0)
  67.  
  68. /*  Loop through the boxes and interpret the function which aligns them */
  69. do i = 1 to counter
  70.  
  71.     boxpos  = ppm_GetBoxPosition( boxes.i )
  72.     boxsize = ppm_GetBoxSize( boxes.i )
  73.  
  74.     interpret "call ppm_SetBoxPosition("newpos")"
  75.  
  76. end
  77. call exit_msg()
  78.  
  79. break_d:
  80. break_e:
  81. break_c:
  82. halt:
  83.     call exit_msg("User aborted Genie!")
  84. /*
  85.  * exit_msg()
  86.  *
  87.  * Description:
  88.  * Exits the Genie with a message
  89.  *
  90.  * Arguments:
  91.  * Message to inform user
  92.  */
  93. exit_msg: procedure expose units
  94. do
  95.     parse arg message
  96.  
  97.     if message ~= '' then
  98.       call ppm_Inform( 1, message, )
  99.  
  100.     call ppm_AutoUpdate( 1 )
  101.  
  102.     if units = 3 then call ppm_SetUnits(3)
  103.     exit
  104.  
  105. end
  106.  
  107. /*
  108.  * SetAlignment()
  109.  *
  110.  * Description:
  111.  * Creates a small arexx program which aligns the boxes based upon input
  112.  *
  113.  * Arguments:
  114.  * Current alignment settings
  115.  *
  116.  * Returns:
  117.  * Returns a string which may be interpreted by arexx
  118.  */
  119.  
  120. SetAlignment: procedure
  121. do
  122.     arg align
  123.  
  124.     if align = 'BOTTOM' then
  125.    return("boxes.i, word(boxpos, 1), (position - word(boxsize, 2))")
  126.  
  127.     if align = 'TOP' then
  128.    return("boxes.i, word(boxpos, 1), position")
  129.  
  130.     if align = 'RIGHT' then
  131.    return("boxes.i, (position - word(boxsize, 1)), word(boxpos, 2)")
  132.  
  133.     if align = 'LEFT' then
  134.    return("boxes.i, position, word(boxpos, 2)")
  135.  
  136.     if align = 'CENTER VERTICALLY' then
  137.    return("boxes.i, (position - word(boxsize,1)/2), word(boxpos, 2)")
  138.  
  139.     if align = 'CENTER HORIZONTALLY' then
  140.    return("boxes.i, word(boxpos, 1 ), (position - word(boxsize,2)/2)")
  141.  
  142.  
  143. end
  144.